﻿// ***********************************************************************
// <copyright file="BGetJokeByKeyWords.cs" company="四川全球通">
// Copyright (c) 四川全球通. All rights reserved.</copyright>
// Assembly         : Tzq.DataService.Buiness
// Author            : 谭志强
// Created          : 2016/1/13 10:48:03
// <summary></summary>
// ***********************************************************************

using Tzq.DataService.Model;
using Common.DBUtility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tzq.DataService.DAL;
using Tzq.DataService.Factory;

namespace Tzq.DataService.Buiness
{
    public class BGetJokes : DbTransaction
    {
        /// <summary>
        /// 数据操作实例
        /// </summary>
        private DQiushibaike qiushibaikeDal = null;

        /// <summary>
        /// 关键字
        /// </summary>
        private string keyWord = string.Empty;

        private int type = 0;
        /// <summary>
        /// 构造函数
        /// </summary>
        public BGetJokes(string keywords)
        {
            this.Connection = ConnectionFactory.SpiderDBRead;
            this.IsBeginTransaction = false;
            this.qiushibaikeDal = new DQiushibaike();
            this.keyWord = keywords;
            this.type = 0;
        }


        /// <summary>
        /// 构造函数
        /// </summary>
        public BGetJokes()
        {
            this.Connection = ConnectionFactory.SpiderDBRead;
            this.IsBeginTransaction = false;
            this.qiushibaikeDal = new DQiushibaike();
            this.type = 1;
        }

        protected override void ExecuteMethods()
        {
            switch (this.type)
            {
                case 0:
                    this.QiushibaikeList = this.qiushibaikeDal.GetJokeByKeyWords(null, this.Connection, this.keyWord);
                    break;
                case 1:
                    this.QiushibaikeList = this.qiushibaikeDal.GetJokeByRandom(null, this.Connection);
                    break;
                default:
                    break;
            }
        }

        /// <summary>
        /// 结果
        /// </summary>
        public List<MQiushibaike> QiushibaikeList
        {
            get;
            set;
        }

    }
}
